package juc.c_012;/*
   Talk is cheap. Show me the code.
 */

import java.util.concurrent.TimeUnit;

/**
 * @Description
 * @Date 2021/6/6
 * @Author liudl
 */
public class T {
    private /*volatile*/ boolean isRunning = true;
    public void m() {
        System.out.println("m start...");
        while (isRunning) {
//            try {
//                TimeUnit.MICROSECONDS.sleep(200);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
        }
        System.out.println("m end...");
    }

    public static void main(String[] args) throws InterruptedException {
        T t = new T();
        new Thread(t::m,"t1").start();
        TimeUnit.SECONDS.sleep(2);
        t.isRunning = false;
    }
}
